package wifiunion.com.notice.widget;


import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.TextView;

import wifiunion.com.notice.R;


/**
 * 通用确认对话框
 * 
 * @author dqcao
 * 
 */
public class TipsDialog extends Dialog {

	private Context context;
    private TextView titleName;
	private TextView cancelTxt;
	private TextView confirmTxt;
	private TextView messgaeEt;


	public TipsDialog(Context context)
	{
		super(context, R.style.alert_dialog);
		this.context = context;
		LayoutInflater li = LayoutInflater.from(context);
		ViewGroup contentView = (ViewGroup) li.inflate(
				R.layout.dialog_tips, null);
		contentView.bringToFront();

		titleName = (TextView) contentView.findViewById(R.id.tv_title_name);
		cancelTxt = (TextView) contentView.findViewById(R.id.cancel_txt);
		confirmTxt = (TextView) contentView.findViewById(R.id.confirm_txt);
		messgaeEt = (TextView) contentView.findViewById(R.id.tv_message);

		setCanceledOnTouchOutside(false);
		WindowManager.LayoutParams lp = getWindow().getAttributes();
		lp.gravity = Gravity.CENTER;
		onWindowAttributesChanged(lp);
		setContentView(contentView);


	}

	public String getEditData()
	{
		String str = null;
		if(null != messgaeEt)
		{
			str = messgaeEt.getText().toString();
		}
	     return  str;
	}


	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		WindowManager.LayoutParams lp = getWindow().getAttributes();
		lp.width = getContext().getResources().getDimensionPixelSize(
				R.dimen.dp_354);
		lp.gravity = Gravity.CENTER;
		getWindow().setAttributes(lp);
	}

	public void setTitleMsg(String  msg) {
		if (titleName != null) {
			titleName.setText(msg);
		}
	}

	public void setCancleText(String text) {
		if (text != null) {
			cancelTxt.setText(text);
		}
	}

	public void setConfirmText(String text) {
		if (text != null) {
			confirmTxt.setText(text);
		}
	}

	public void setMsgHint(String text)
	{
		if(text != null)
		{
			messgaeEt.setText(text);
		}

	}

	public void setComfirmListener(
			android.view.View.OnClickListener okListener) {
		if (confirmTxt != null) {
			confirmTxt.setOnClickListener(okListener);
		}
	}

	public void setCancelListener(android.view.View.OnClickListener okListener) {
		if (cancelTxt != null) {
			cancelTxt.setOnClickListener(okListener);
		}
	}


}
